feat(usage): track logins per user with date range filter#797
Open
ismaeldosil wants to merge 2 commits intodevelopfrom
Open
feat(usage): track logins per user with date range filter#797ismaeldosil wants to merge 2 commits intodevelopfrom
ismaeldosil wants to merge 2 commits intodevelopfrom
Conversation
- Backend: write loginEvents doc on each signin (preserves lastLogin) - Backend: getUsersLoginCounts(start, end) batch aggregation - UI: date range picker on All Users dashboard with 7d/30d/90d presets - UI: new Logins column with sort, alongside existing Last Login - CSV export includes login count for selected range - Default range: last 30 days Closes CHALK-110 Closes CHALK-111 Closes CHALK-112 Closes CHALK-113 Closes CHALK-114
The /LeadersAllUsers route also renders <AllUsersTable> and was missing the new required props introduced for login tracking. Adds parallel load via Promise.all and a range-change handler matching the AllUsersPage pattern. Closes CHALK-115
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements per-user login tracking with a configurable date-range filter on the All Users dashboard. Existing
lastLoginfield only stored the most recent login (overwritten on each signin); this adds aloginEventscollection capturing one document per signin so administrators can see usage frequency.Closes CHALK-110, CHALK-111, CHALK-112, CHALK-113, CHALK-114.
Changes
Backend (
Firebase.tsx)firebaseEmailSignInwrites a doc to a newloginEventscollection on every successful login ({ userId, timestamp }). The existinglastLoginfield update is preserved for backward compatibility.getUsersLoginCounts(start, end): single batch query againstloginEventsfiltered by timestamp, buildsMap<userId, count>in memory. Same optimized pattern asgetUsersLastAction().UI (
AllUsersTable.tsx,AllUsersPage.tsx)@material-ui/pickers, already in deps) with quick presets: Last 7d / 30d / 90d.Logins (Apr 8 – May 8)).State management
AllUsersPageloads users and counts in parallel (Promise.all) on mount.getUsersLoginCounts(users are not re-queried).Architectural notes
Login counts begin from the deploy date forward. Past logins were never captured as discrete events — only the most recent was stored (and overwritten). This will be communicated to the client on delivery.
Test plan
loginEvents